home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#42 (Mar 89)
/
calc source
/
DrawGrid.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-12-09
|
1KB
|
47 lines
#include <ListMgr.h>
#include <WindowMgr.h>
#include <MacTypes.h>
#include <QuickDraw.h>
#include "MacCalc.h"
#include "SheetHndlg.h"
int DrawGrid( win_ptr )
WindowPtr win_ptr ;
{
GrafPtr tmp_port ;
Rect win_rect ;
int bottom ;
int right ;
int num_h_lines ;
int num_v_lines ;
int i, max ;
GetPort( &tmp_port ) ;
SetPort( win_ptr ) ;
PenNormal( ) ;
PenPat( gray ) ;
win_rect = win_ptr->portRect ;
bottom = win_rect.bottom - 15 ;
right = win_rect.right - 15 ;
num_h_lines = bottom / CELL_HEIGTH ;
num_v_lines = right / CELL_WIDTH ;
max = ( num_h_lines > num_v_lines ) ? num_h_lines:num_v_lines ;
for( i = 1 ; i <= max ; i++ ) {
if( i < num_h_lines ) {
MoveTo( 0, i*CELL_HEIGTH ) ;
LineTo( right, i*CELL_HEIGTH ) ;
}
if( i < num_v_lines ) {
MoveTo( i*CELL_WIDTH, 0 ) ;
LineTo( i*CELL_WIDTH, bottom ) ;
}
}
PenNormal( ) ;
SetPort( tmp_port ) ;
return ;
}